package com.example.demo;

import com.example.demo.extend.Parent;
import com.example.demo.extend.Son;
import com.example.test.advice.第三章_类_对象_方法.建议41_让多继承成为现实.Father;

import java.util.ArrayList;
import java.util.List;

public class TestConvert {

    public static void main(String[] args) {
        List<Parent> parentList = new ArrayList<Parent>();
        Parent father = new Parent();
        father.setAge(100);
        father.setName("父亲");
        parentList.add(father);
        List<? super Parent> sonList = new ArrayList<>();
        Son son = new Son();
        son.setName("儿子");
        son.setAge(11);
        son.setFather(father.getName());
        sonList.add(son);

        //getPersonInfo(parentList);
        getPersonInfo((List<Parent>) sonList);

    }

    static void getPersonInfo(List<Parent> fatherList){
        for(Parent parent:fatherList){
            System.out.println(parent.getName());
        }
    }
}
